/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bff.slimserver.utils;

import com.bff.slimserver.musicjukebox.lib.JukeboxProperties;
import java.util.Comparator;
import org.bff.slimserver.musicobjects.SlimObject;

/**
 *
 * @author bill
 */
public class SlimComparator implements Comparator<SlimObject> {

    private boolean includeThe;

    public SlimComparator() {
        includeThe = JukeboxProperties.getInstance().isIncludeThe();
    }

    @Override
    public int compare(SlimObject t1, SlimObject t2) {
        String name1 = includeThe ? t1.getName().toUpperCase() : t1.getName().toUpperCase().replaceAll("^THE ", "").toUpperCase();
        String name2 = includeThe ? t2.getName().toUpperCase() : t2.getName().toUpperCase().replaceAll("^THE ", "").toUpperCase();

        return name1.compareTo(name2);
    }

}
